package com.njitweb.service.impl;

import com.njitweb.constant.GoodConstant;
import com.njitweb.mapper.GoodMapper;
import com.njitweb.pojo.Goods;
import com.njitweb.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class GoodServiceImpl implements GoodService {

    @Autowired
    private GoodMapper goodDao;
    @Override
    public void addGoods(Goods good) {
        //状态 默认是上架的
        good.setStatus(GoodConstant.LISTED);
        good.setCreatedAt(new Date());
        good.setUpdatedAt(new Date());
        goodDao.addGood(good);
    }

    @Override
    public List<Goods> listGoods() {
        return goodDao.listGoods();
    }

    @Override
    public void deleteGoods(Integer id) {
         goodDao.deleteById(id);
    }

    @Override
    public void modifyStatus(Integer id, Integer status) {
        goodDao.modifyStatus(id,status);
    }
}
